package o;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
import com.huawei.appgallery.assistantdock.buoydock.uikit.navigator.NavigatorMaxWidthLinearLayout;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.hwid.core.constants.HwAccountConstants;
import huawei.widget.HwSubTabWidget;
import huawei.widget.HwSubTabWidget.b;
import java.lang.ref.WeakReference;
import java.util.List;

public class bha extends bgz {
    private List<bgl> ʼ;
    private NavigatorMaxWidthLinearLayout ʽ;
    protected int ˊ = 0;
    protected ViewPager ˋ;
    protected dey ˎ = null;
    private GameInfo ˏ;
    private HwSubTabWidget ॱ;

    static class a implements ViewPager.OnPageChangeListener {
        private WeakReference<HwSubTabWidget> ˏ;

        a(HwSubTabWidget hwSubTabWidget) {
            this.ˏ = new WeakReference(hwSubTabWidget);
        }

        public void onPageScrolled(int i, float f, int i2) {
            if (this.ˏ != null) {
                HwSubTabWidget hwSubTabWidget = (HwSubTabWidget) this.ˏ.get();
                if (hwSubTabWidget != null) {
                    hwSubTabWidget.setSubTabScrollingOffsets(i, f);
                }
            }
        }

        public void onPageScrollStateChanged(int i) {
            if (this.ˏ != null) {
                HwSubTabWidget hwSubTabWidget = (HwSubTabWidget) this.ˏ.get();
                if (hwSubTabWidget != null) {
                    hwSubTabWidget.setSubTabSelected(i);
                }
            }
        }

        public void onPageScrolled(int i) {
        }
    }

    static class c implements b {
        private List<bgl> ˊ;
        private ViewPager ˎ;

        c(List<bgl> list, ViewPager viewPager) {
            this.ˎ = viewPager;
            this.ˊ = list;
        }

        public void ˊ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        }

        public void ˎ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
            if (Logger.ˎ()) {
                Logger.ˏ("MainSegment", "onSubTabSelected");
            }
            if (aVar == null) {
                Logger.e("MainSegment", "onSubTabSelected, tab == null");
            } else if (this.ˎ != null) {
                if (this.ˎ.getCurrentItem() != aVar.ˏ()) {
                    this.ˎ.setCurrentItem(aVar.ˏ());
                }
                ॱ(aVar);
            }
        }

        public void ॱ(huawei.widget.HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        }

        private void ॱ(huawei.widget.HwSubTabWidget.a aVar) {
            if (!CollectCheck.isEmpty(this.ˊ)) {
                bgl o_bgl = (bgl) this.ˊ.get(aVar.ˏ());
                if (o_bgl != null) {
                    bgi.ˋ().ˏ(o_bgl.ˋ() + "_" + UserSession.getInstance().getUserId());
                    Logger.ˎ("MainSegment", "onTabSelected, tabInfo = " + o_bgl.ॱ());
                }
            }
        }
    }

    public static bha ˋ(Context context, Bundle bundle) {
        bha o_bha = new bha();
        o_bha.ˊ(bundle);
        o_bha.ˊ(context);
        return o_bha;
    }

    public void ˊ(dey o_dey) {
        this.ˎ = o_dey;
    }

    public void ॱ(@Nullable Bundle bundle) {
        super.ॱ(bundle);
        if (ˉ() == null) {
            Logger.e("MainSegment", "onCreate, context is null");
        } else {
            bhj.ˊ();
        }
    }

    public View ˋॱ() {
        if (ˉ() == null || this.ˎ == null) {
            Logger.e("MainSegment", "onCreateView, context = " + ˉ() + ", segmentManager = " + this.ˎ);
            return null;
        }
        ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(ˉ()).inflate(ॱ(), null, false);
        ˋ(viewGroup);
        return viewGroup;
    }

    protected int ॱ() {
        return beo$j.ʿ;
    }

    protected void ˋ(ViewGroup viewGroup) {
        this.ˋ = (ViewPager) viewGroup.findViewById(beo$e.ˊˋ);
        this.ʽ = (NavigatorMaxWidthLinearLayout) viewGroup.findViewById(beo$e.ˊᐝ);
        this.ॱ = (HwSubTabWidget) viewGroup.findViewById(beo$e.ˌ);
        ˎ();
    }

    private void ˎ() {
        if (this.ˏ == null) {
            Logger.e("MainSegment", "initPagerView, gameInfo == null");
            return;
        }
        ezo ˋ = ezs.ˏ().ˋ(this.ˏ);
        if (ˋ == null || CollectCheck.isEmpty(ˋ.ˏ())) {
            Object obj;
            String str = "MainSegment";
            StringBuilder append = new StringBuilder().append("initPagerView, entryInfo = ").append(ˋ).append(", getTabs() = ");
            if (ˋ == null) {
                obj = HwAccountConstants.NULL;
            } else {
                obj = Boolean.valueOf(CollectCheck.isEmpty(ˋ.ˏ()));
            }
            Logger.e(str, append.append(obj).toString());
            return;
        }
        this.ʼ = ˋ.ˏ();
        if (this.ʽ != null) {
            this.ʽ.setColumnCount(this.ʼ.size());
        }
        if (1 == this.ʼ.size() && this.ॱ != null) {
            this.ॱ.setVisibility(8);
        }
        if (this.ˋ != null) {
            try {
                PagerAdapter o_bhg = new bhg(ˉ(), this.ʼ, this.ˎ);
                ˊ(this.ʼ);
                this.ˋ.setAdapter(o_bhg);
                this.ˋ.addOnPageChangeListener(new a(this.ॱ));
                if (this.ˊ >= 0 && this.ˊ < this.ʼ.size()) {
                    this.ˋ.setCurrentItem(this.ˊ);
                    o_bhg.setViewPagerObserver(this.ˊ);
                }
                o_bhg.notifyDataSetChanged();
            } catch (Throwable e) {
                Logger.ˋ("MainSegment", "initPagerView", e);
            }
        }
    }

    private void ˊ(List<bgl> list) {
        if (this.ॱ != null && !CollectCheck.isEmpty(list)) {
            int size = list.size();
            int i = 0;
            while (i < size) {
                bgl o_bgl = (bgl) list.get(i);
                HwSubTabWidget hwSubTabWidget = this.ॱ;
                hwSubTabWidget.getClass();
                huawei.widget.HwSubTabWidget.a aVar = new huawei.widget.HwSubTabWidget.a(hwSubTabWidget, o_bgl.ॱ(), new c(list, this.ˋ));
                aVar.ˎ(i);
                this.ॱ.ॱ(aVar, i == 0);
                i++;
            }
        }
    }

    public void A_() {
        super.A_();
    }

    public void ˊ(GameInfo gameInfo) {
        this.ˏ = gameInfo;
    }

    protected void ͺ() {
        if (ˊˊ() != null) {
            this.ˊ = ˊˊ().getInt("DEFAULT_PAGE_NUM", 0);
        }
    }
}
